<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 模糊查询
      var arr = ['aaa', 'abc', 'bbc', 'ccd', 'ddd', 'bcd']

      // 数组 filter 字符串 indexOf
      var input = prompt('请输入查询的内容')
      var res = arr.filter(function (item) {
        return item.indexOf(input) !== -1
      })
      console.log(res) //['abc', 'bbc', 'bcd']
    </script>
  </body>
</html>
